package com.travel.controller.admin;

import com.travel.pojo.dto.PageDTO;
import com.travel.pojo.dto.UserDTO;
import com.travel.pojo.dto.UserQueryDTO;
import com.travel.pojo.entity.User;
import com.travel.pojo.vo.UserVO;
import com.travel.service.IUserService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;


@RestController("adminUserController")
@RequestMapping("/admin/user")
@Slf4j
@RequiredArgsConstructor
public class UserController {

    private final IUserService userService;

    @PostMapping("/list")
    public PageDTO<UserVO> pageListUser(@RequestBody UserQueryDTO userQueryDTO) {
        log.info("分页数据为：{}", userQueryDTO);
        return userService.pageListUser(userQueryDTO);
    }

    @DeleteMapping("/{id}")
    public void deleteUser(@PathVariable Long id) {
        userService.removeById(id);
    }

    @PostMapping("/addUser")
    public void addUser(@RequestBody UserDTO userDTO) {
        log.info("修改为：{}", userDTO);
        userService.addUser(userDTO);
    }

    @PutMapping("/updateUser/{id}")
    public void updateUser(@PathVariable Long id, @RequestBody UserDTO userDTO) {
        log.info("修改人id为：{},修改内容为：{}", id, userDTO);
        userService.updateUser(id, userDTO);
    }




}
